package com.hb.software.service.impl;


import com.hb.software.dao.BaseDao;
import com.hb.software.domain.BaseEntity;
import com.hb.software.service.BaseService;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;


@Transactional
public class BaseServiceImpl<T extends BaseEntity<PK>, PK extends Serializable> implements BaseService<T, PK> {

    protected BaseDao<T, PK> dao;

    @Override
    public void save(T t) {

        this.dao.save(t);
    }

    public void delete(long id) {

        this.dao.delete(id);
    }

    public List findAll() {

        return this.dao.findAll();
    }

    @Override
    public long selectCount() {

        return this.dao.selectCount();
    }

    @Override
    public List<T> findList(long id) {
        return this.dao.findList(id - 20, id);
    }

    @Override
    public long findLastId() {
        return this.dao.findLastId();
    }


    public T findById(long id) {

        return this.dao.findOne(id);

    }

    @Override
    public void deleteAll() {

        this.dao.deleteAll();
    }

    @Override
    public T findOne(long k) {

        return this.dao.findOne(k);
    }

    @Override
    public void update(T t) {

        this.dao.update(t);
    }

    @Override
    public Long findTotals() {
        return this.dao.findTotals();
    }

    @Override
    public List<T> findByPage(Integer pageNow, Integer pageSize) {
        int start = (pageNow - 1) * pageSize;
        return this.dao.findByPage(start, pageSize);
    }


}
